package com.atguigu.srb.oss.controller;

import com.atguigu.srb.common.result.R;
import com.atguigu.srb.oss.service.OssService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "阿里云文件管理")
//@CrossOrigin
@RestController
@RequestMapping("/api/oss/file")
public class ApiOssController {
    @Autowired
    OssService ossService;

    @PostMapping("/uploadImage")
    public R uploadImage(@RequestParam("file")MultipartFile multipartFile,@RequestParam String module){
        String url = ossService.uploadImage(multipartFile,module);
        return R.ok().data("url",url);
    }

    @DeleteMapping("/removeFile")
    public R removeFile(@RequestParam("url")String url){
        ossService.removeFile(url);
        return R.ok();
    }


}
